#define _CRT_SECURE_NO_WARNINGS 1
#include<bitset>
#include<iostream>
#include<unordered_map>
using namespace std;

#if 0
void Test()
{
	bitset<24> bs;

	int array[] = { 1, 3, 7, 4, 12, 16, 19, 13, 22, 18 };
  	for (auto e : array)
	{
		bs.set(e);
	}
	cout << bs.count() << endl;
	cout << bs.size() << endl;
	if (bs.test(20))
	{
		cout << "true" << endl;
	}
	else
	{
		cout << "false" << endl;
	}
}
int main()
{
	Test();
	return 0;
}
#endif

struct TreeNode {
	int val;
	TreeNode *left;
	TreeNode *right;
	TreeNode() : val(0), left(nullptr), right(nullptr) {}
	TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
	TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
};

unordered_map<int, int> map;
int max_num = INT_MIN;
void StaNum(TreeNode* root)
{
	if (root == nullptr)
	{
		return;
	}
	map[root->val]++;
	StaNum(root->left);
	StaNum(root->right);
}
vector<int> findMode(TreeNode* root) {
	vector<int> arr;
	StaNum(root);
	for (auto e : map)
	{
		if (e.first>max_num)
		{
			max_num = e.first;
		}
	}
	for (auto e : map)
	{
		if (e.first == max_num)
		{
			arr.push_back(e.second);
		}
	}
	return arr;
}